unit io_imagecapture_const;

{
  Constants used by io_imagecapture_basic.
}

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, basicio_city, basicio_street, basicio_const, basicio_Field, graphics,
  basicio_player;

type
  TFieldRect = record
    FieldX,FieldY: integer;
    PixelX,PixelY: integer;
  end;

  TCityRect = record
    CityX,CityY: integer;
    PixelX,PixelY: integer;
  end;

  TStreetRect = record
    PixelX, PixelY: integer;
  end;

  TCityColor = record
    Player: TPlayerColor;
    Color: TColor;
    Extended: boolean;
  end;

const
  ChatRect:   TRect = (Left:1;   Top:731; Right:950; Bottom:925);
  FieldRect:  TRect = (Left:2;   Top:26;  Right:637; Bottom:727);
  ResRect:    TRect = (Left:640; Top:537; Right:1095;Bottom:718);
  BuildRect:  TRect = (Left:686; Top:36;  Right:1048;Bottom:144);
  TradeRect:  TRect = (Left:901; Top:174; Right:1080;Bottom:514);
  StatusRect: TRect = (Left:640; Top:165; Right:899; Bottom:520);

  ClientWindowWidth  = 1100;
  ClientWindowHeight = 950;

  ColorWood  = 3844970;
  ColorDirt  = 8702701;
  ColorSheeps= 904842;
  ColorWheat = 3138045;
  ColorOre   = 11979726;
  ColorTHief = 1653601;
  ColorDesert= 6616040;

  FieldResRectWidth = 20;
  FieldResRectHeight= 29;
  FieldResRectArray: array[0..18] of TFieldRect= (
    (FieldX:01;FieldY:01;PixelX:310;PixelY:193),
    (FieldX:02;FieldY:01;PixelX:223;PixelY:243),
    (FieldX:02;FieldY:02;PixelX:396;PixelY:243),
    (FieldX:03;FieldY:01;PixelX:137;PixelY:293),
    (FieldX:03;FieldY:02;PixelX:310;PixelY:293),
    (FieldX:03;FieldY:03;PixelX:483;PixelY:293),
    (FieldX:04;FieldY:01;PixelX:223;PixelY:344),
    (FieldX:04;FieldY:02;PixelX:396;PixelY:344),
    (FieldX:05;FieldY:01;PixelX:137;PixelY:394),
    (FieldX:05;FieldY:02;PixelX:310;PixelY:394),
    (FieldX:05;FieldY:03;PixelX:483;PixelY:394),
    (FieldX:06;FieldY:01;PixelX:223;PixelY:445),
    (FieldX:06;FieldY:02;PixelX:396;PixelY:445),
    (FieldX:07;FieldY:01;PixelX:137;PixelY:495),
    (FieldX:07;FieldY:02;PixelX:310;PixelY:495),
    (FieldX:07;FieldY:03;PixelX:483;PixelY:495),
    (FieldX:08;FieldY:01;PixelX:223;PixelY:546),
    (FieldX:08;FieldY:02;PixelX:396;PixelY:546),
    (FieldX:09;FieldY:01;PixelX:310;PixelY:596));

  FieldDiceOffsetHeight = -28;
  FieldDiceOffsetWidth  = -5;
  FieldDiceWidth        = 28;
  FieldDiceHeight       = 28;

  ResCountRect: array[0..9] of TRect = ((Left:8 ;Top:13 ;Right:27 ;Bottom:29 ), // wood
                                        (Left:98;Top:13 ;Right:117;Bottom:29 ), // dirt
                                        (Left:188;Top:13 ;Right:207;Bottom:29 ), // sheeps
                                        (Left:278;Top:13 ;Right:297;Bottom:29 ), // wheat
                                        (Left:368;Top:13 ;Right:387;Bottom:29 ), // ore
                                        (Left:60 ;Top:103;Right:79 ;Bottom:119), // knights
                                        (Left:150;Top:103;Right:169;Bottom:119), // winpoints
                                        (Left:240;Top:103;Right:259;Bottom:119), // monopolies
                                        (Left:330;Top:103;Right:349;Bottom:119), // inventions
                                        (Left:421;Top:103;Right:440;Bottom:119)  // streets
                                       );
  HarborKindRect: array[0..8] of TRect = (
      (Left:306;Top: 95;Right:310;Bottom:102), // Harbor_1 (top)
      (Left:457;Top:178;Right:464;Bottom:181), // Harbor_2 (top right)
      (Left:540;Top:329;Right:549;Bottom:333), // Harbor_3 (upper right)
      (Left:536;Top:530;Right:540;Bottom:534), // Harbor_4 (lower right)
      (Left:377;Top:582;Right:386;Bottom:596), // Harbor_5 (bottom right)
      (Left:245;Top:582;Right:260;Bottom:591), // Harbor_6 (bottom left)
      (Left: 91;Top:528;Right:100;Bottom:533), // Harbor_7 (lower left)
      (Left: 86;Top:327;Right: 95;Bottom:331), // Harbor_8 (upper left)
      (Left:172;Top:176;Right:185;Bottom:180)  // Harbor_9 (top left)
      );
  HarborKindColor: array[0..4] of TColor = (
      (45568),   // wood 2:1
      (36018),   // dirt 2:1     626352  ???
      (65280),   // sheeps 2:1
      (65278),   // wheat 2:1
      (8421504) // ore 2:1      9081233  ???
     );
  DiceMarkPoint: array[0..1] of array[0..3] of TPoint =(((x:18;y:47), (x:33;y:47), (x:26;y:41),(x:33;y:34)),
                                                        ((x:85;y:47), (x:100;y:47),(x:93;y:41),(x:99;y:34)) );

  TurnStatusRect: TRect = (Left:135;Top:0;Right:259;Bottom:173);

  CityHoricontalDifShort  = 28;
  CityHoricontalDifLong   = 58;
  CityVerticalDif         = 50;

  CityPosArray: array[0..53] of TCityRect= (
       (CityX:1;CityY:3;PixelX:110;PixelY:228),
       (CityX:1;CityY:4;PixelX:90;PixelY:278),
       (CityX:1;CityY:5;PixelX:110;PixelY:328),
       (CityX:1;CityY:6;PixelX:90;PixelY:379),
       (CityX:1;CityY:7;PixelX:110;PixelY:429),
       (CityX:1;CityY:8;PixelX:90;PixelY:480),
       (CityX:1;CityY:9;PixelX:110;PixelY:530),

       (CityX:2;CityY:2;PixelX:202;PixelY:177),
       (CityX:2;CityY:3;PixelX:176;PixelY:228),
       (CityX:2;CityY:4;PixelX:202;PixelY:278),
       (CityX:2;CityY:5;PixelX:176;PixelY:328),
       (CityX:2;CityY:6;PixelX:202;PixelY:379),
       (CityX:2;CityY:7;PixelX:176;PixelY:429),
       (CityX:2;CityY:8;PixelX:202;PixelY:480),
       (CityX:2;CityY:9;PixelX:176;PixelY:530),
       (CityX:2;CityY:10;PixelX:202;PixelY:580),

       (CityX:3;CityY:1;PixelX:288;PixelY:127),
       (CityX:3;CityY:2;PixelX:260;PixelY:177),
       (CityX:3;CityY:3;PixelX:288;PixelY:228),
       (CityX:3;CityY:4;PixelX:260;PixelY:278),
       (CityX:3;CityY:5;PixelX:288;PixelY:328),
       (CityX:3;CityY:6;PixelX:260;PixelY:379),
       (CityX:3;CityY:7;PixelX:288;PixelY:429),
       (CityX:3;CityY:8;PixelX:260;PixelY:480),
       (CityX:3;CityY:9;PixelX:288;PixelY:530),
       (CityX:3;CityY:10;PixelX:260;PixelY:580),
       (CityX:3;CityY:11;PixelX:288;PixelY:630),

       (CityX:4;CityY:1;PixelX:346;PixelY:127),
       (CityX:4;CityY:2;PixelX:374;PixelY:177),
       (CityX:4;CityY:3;PixelX:346;PixelY:228),
       (CityX:4;CityY:4;PixelX:374;PixelY:278),
       (CityX:4;CityY:5;PixelX:346;PixelY:328),
       (CityX:4;CityY:6;PixelX:374;PixelY:379),
       (CityX:4;CityY:7;PixelX:346;PixelY:429),
       (CityX:4;CityY:8;PixelX:374;PixelY:480),
       (CityX:4;CityY:9;PixelX:346;PixelY:530),
       (CityX:4;CityY:10;PixelX:374;PixelY:580),
       (CityX:4;CityY:11;PixelX:346;PixelY:630),

       (CityX:5;CityY:2;PixelX:432;PixelY:177),
       (CityX:5;CityY:3;PixelX:460;PixelY:228),
       (CityX:5;CityY:4;PixelX:432;PixelY:278),
       (CityX:5;CityY:5;PixelX:460;PixelY:328),
       (CityX:5;CityY:6;PixelX:432;PixelY:379),
       (CityX:5;CityY:7;PixelX:460;PixelY:429),
       (CityX:5;CityY:8;PixelX:432;PixelY:480),
       (CityX:5;CityY:9;PixelX:460;PixelY:530),
       (CityX:5;CityY:10;PixelX:432;PixelY:580),

       (CityX:6;CityY:3;PixelX:518;PixelY:228),
       (CityX:6;CityY:4;PixelX:546;PixelY:278),
       (CityX:6;CityY:5;PixelX:518;PixelY:328),
       (CityX:6;CityY:6;PixelX:546;PixelY:379),
       (CityX:6;CityY:7;PixelX:518;PixelY:429),
       (CityX:6;CityY:8;PixelX:546;PixelY:480),
       (CityX:6;CityY:9;PixelX:518;PixelY:530)); // Pixels are Edges of the Streets

  StreetPointArray: array [0..71] of TStreetRect=((PixelX:103; PixelY:248),
                                                  (PixelX:162; PixelY:229),
                                                  (PixelX:97; PixelY:298),
                                                  (PixelX:103; PixelY:350),
                                                  (PixelX:166; PixelY:328),
                                                  (PixelX:101; PixelY:406),
                                                  (PixelX:102; PixelY:449),
                                                  (PixelX:165; PixelY:430),
                                                  (PixelX:95; PixelY:498),
                                                  (PixelX:166; PixelY:530),

                                                  (PixelX:188; PixelY:200),
                                                  (PixelX:253; PixelY:178),
                                                  (PixelX:187; PixelY:255),
                                                  (PixelX:254; PixelY:278),
                                                  (PixelX:190; PixelY:300),
                                                  (PixelX:189; PixelY:359),
                                                  (PixelX:189; PixelY:401),
                                                  (PixelX:253; PixelY:380),
                                                  (PixelX:188; PixelY:457),
                                                  (PixelX:190; PixelY:499),
                                                  (PixelX:251; PixelY:480),
                                                  (PixelX:186; PixelY:558),
                                                  (PixelX:254; PixelY:580),

                                                  (PixelX:274; PixelY:149),
                                                  (PixelX:341; PixelY:127),
                                                  (PixelX:273; PixelY:205),
                                                  (PixelX:275; PixelY:247),
                                                  (PixelX:340; PixelY:229),
                                                  (PixelX:273; PixelY:304),
                                                  (PixelX:277; PixelY:348),
                                                  (PixelX:342; PixelY:329),
                                                  (PixelX:274; PixelY:406),
                                                  (PixelX:274; PixelY:449),
                                                  (PixelX:341; PixelY:429),
                                                  (PixelX:270; PixelY:506),
                                                  (PixelX:271; PixelY:556),
                                                  (PixelX:342; PixelY:531),
                                                  (PixelX:270; PixelY:605),
                                                  (PixelX:343; PixelY:631),

                                                  (PixelX:360; PixelY:150),
                                                  (PixelX:362; PixelY:199),
                                                  (PixelX:427; PixelY:178),
                                                  (PixelX:359; PixelY:252),
                                                  (PixelX:362; PixelY:298),
                                                  (PixelX:427; PixelY:278),
                                                  (PixelX:360; PixelY:353),
                                                  (PixelX:361; PixelY:400),
                                                  (PixelX:426; PixelY:379),
                                                  (PixelX:359; PixelY:457),
                                                  (PixelX:361; PixelY:505),
                                                  (PixelX:423; PixelY:480),
                                                  (PixelX:360; PixelY:555),
                                                  (PixelX:363; PixelY:605),
                                                  (PixelX:425; PixelY:581),

                                                  (PixelX:451; PixelY:203),
                                                  (PixelX:447; PixelY:247),
                                                  (PixelX:511; PixelY:229),
                                                  (PixelX:443; PixelY:303),
                                                  (PixelX:446; PixelY:348),
                                                  (PixelX:512; PixelY:328),
                                                  (PixelX:447; PixelY:408),
                                                  (PixelX:447; PixelY:448),
                                                  (PixelX:513; PixelY:429),
                                                  (PixelX:447; PixelY:509),
                                                  (PixelX:445; PixelY:555),
                                                  (PixelX:510; PixelY:529),

                                                  (PixelX:537; PixelY:255),
                                                  (PixelX:536; PixelY:302),
                                                  (PixelX:533; PixelY:348),
                                                  (PixelX:536; PixelY:404),
                                                  (PixelX:535; PixelY:455),
                                                  (PixelX:532; PixelY:510)
);

  CityColors: array [0..11] of TCityColor = (
    (player:PC_white;color:8887744;  extended:false),
    (player:PC_white;color:9940951;  extended:false),
    (player:PC_white;color:7703214;  extended:false),
    (player:PC_white;color:8158872;  extended:false),

    (player:PC_white;color:11057358; extended:true),

    (player:PC_red;color:2243010;    extended:false),

    (player:PC_red;color:2175464;    extended:true),

    (player:PC_Yellow;color:2523559; extended:false),
    (player:PC_Yellow;color:1481929; extended:false),

    (player:PC_Yellow;color:1161192; extended:true),

    (player:PC_blue;color:9256798;   extended:false),
    (player:PC_blue;color:12729165;  extended:true)
    );

  ColorWhite  = clwhite;
  ColorRed    = clred;
  ColorYellow = 51455;
  ColorBlue   = clblue;




  function CityCorToPos(APos: TCityPosition): TPoint;
  function StreetCorToPos(APos: TStreetPosition): TPoint;
  function FieldCorToPos(APos: TFieldPosition): TPoint;

implementation

function CityCorToPos(APos: TCityPosition): TPoint;
var
  i: integer;
begin
   result.x := 0;
   result.y := 0;
   for i:=low(CityPosArray) to high(CityPosArray) do
   begin
     if (CityPosArray[i].CityX = APos.x) and (CityPosArray[i].CityY = APos.y) then
     begin
       result.x := CityPosArray[i].PixelX;
       result.y := CityPosArray[i].PixelY;
       exit;
   end;
end;
end;

function StreetCorToPos(APos: TStreetPosition): TPoint;
var
  i: integer;
  function equal(const a, b: TStreetPosition): boolean;
  begin
    result := ((a[0]=b[0]) and (a[1]=b[1])) or ((a[0]=b[1]) and (a[1]=b[0]));
  end;
begin
  result.x := 0;
  result.y := 0;
  for i:=low(StreetPosArray) to high(StreetPosArray) do
  begin
    if equal(StreetPosArray[i],APos) then
    begin
      result.x := StreetPointArray[i].PixelX;
      result.y := StreetPointArray[i].PixelY;
    end;
  end;
end;

function FieldCorToPos(APos: TFieldPosition): TPoint;
var
  i: integer;
begin
  for i:=low(ResCountRect) to high(ResCountRect) do
  begin
    if (FieldResRectArray[i].FieldX = APos.x) and (FieldResRectArray[i].FieldY = APos.Y) then
    begin
      result.x:= FieldResRectArray[i].pixelx;
      result.y:= FieldResRectArray[i].pixely;
    end;
  end;
end;


end.

